		$('.right-titleicon').on("click",function(e){
			projectVM.createForm();
		})

		mui.plusReady(function(){
			let pageId = plus.webview;
			 window.addEventListener('reloadPage', function(event) {//A页面自定义事件
				projectVM.page = 1;
				projectVM.transformListGet();
			 });
			 mui.neiosCommon.getLocalData("zqtab",function(ret){
			 	console.log("查询:"+JSON.stringify(ret))
				
			 },function(err){
			 	console.log(JSON.stringify(err))
			 })
		});
		let that;
		projectVM = new Vue({
			el: "#content",
			data(){
				return{
					searchType:'todo',
					configFormater:{},//config 配置项
					onStatus:false,
					showPop:false,
					showMenu:false,
					menuList:[
						{name:'新增',path:'detail.html'},{name:'列表',path:'index.html'},
					],
					filterText:'all', //筛选条件
					list:[],//列表List
					modifyBy:"",//当前办理人Id
					page:1,
					keyWord:"",//搜索关键字
				}

			},
			created: function() {
				that = this;
				setTimeout(that.downCode,100)
				that.getUserInfo()
			},
			mounted(){

			},
			methods: {
				searchList(e){
					that.page = 1;
					that.transformListGet()
				},
				//清理 storage
				clearnStorage(){
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM_TRANSFORM_INFO;
					mui.neioConfig.setStorage(pageKey,"")
				},
				//获取用户信息 -- 之后删除
				getUserInfo(){
					mui.neiosCommon.getUserInfo(function(ret){
						let persionData = JSON.parse(localStorage.getItem("neiosUser"));
						that.modifyBy = persionData.userId;
						setTimeout(that.downCode,100)
					})
				},
				enterSearch() {
					if(event.keyCode == 13) { //用户点击回车的事件号为13
						console.log(event.keyCode )
				    }
				},
				doTest(){
					let config = mui.neioConfig.getNeioConfig();
					mui.neioConfig.setStorage(config.PROCESSINGTYPE,"2")
					let status = mui.neioConfig.getStorage(config.PROCESSINGTYPE)
					console.log(status)
				},
				//加载码表数据
				downCode(){
					//获取Config
					let config = mui.neioConfig.getNeioConfig();
					//清空存储
					let pageKey = config.KEYS.PAGE_PARAM;
					let pageKeyInfo = config.KEYS.PAGE_PARAM_TRANSFORM_INFO;
					mui.neioConfig.setStorage(pageKey,"")
					mui.neioConfig.setStorage(pageKeyInfo,"")
					
					this.configFormater = config;
					//获取变压器码表 数据字典编码
					let transformerType = this.configFormater.TRANSFORMER_TYPE;
					let dictCodes = transformerType;
					//获取码表
					let dict = mui.neiosCommon.queryDict(dictCodes,function(data){
						if (data != '') {
							//获取变压器字典表Key
							let config = mui.neioConfig.getNeioConfig();
							let key = that.configFormater.KEYS.TRANSFORMER_CODE_LIST;
							//存入变压器类型数据
							mui.neioConfig.setStorage(key,JSON.stringify(data.TRANS_TYPE))
							that.transformListGet()
						}
					})
					
				},
				//解析码表并加载返回
				analysis(code){
					//获取码表Key
					if(undefined == code){
						return;
					}
					let key = that.configFormater.KEYS.TRANSFORMER_CODE_LIST;
					//获取内存中的码表数据
					let transformerCodes = mui.neioConfig.getStorage(key)
					let datad = JSON.parse(transformerCodes)
					//解码变压器类型
					let type = mui.neiosCommon.dictTransform(datad,code);
					return type;
				},
				queryDictList () {
					let dictCodes = 'TRAINING_SOURCE,NET_SAFE_INFO';
					let dict = mui.neiosCommon.queryDict(dictCodes,function(data){
						if (data != '') {
							this.TRAINING_SOURCE = data.TRAINING_SOURCE
							this.NET_SAFE_INFO = data.NET_SAFE_INFO
							console.log(mui.neiosCommon.dictTransform(this.TRAINING_SOURCE,'0'))
						}
					})
				},
				clickStop(){

				},
				//获取列表信息
				transformListGet(){
					let config = mui.neioConfig.getNeioConfig();
					let url = config.URL.queryTransOperate
					let persionData = JSON.parse(localStorage.getItem("neiosUser"));
					that.modifyBy = persionData.userId;//获取当前登录人
					let params = {};
					params.areaCompanyCode = persionData.companyNewCode;
					params.stationCode = localStorage.getItem('neiosStationCode') == null ? '1020' : localStorage.getItem('neiosStationCode');
					params.role = persionData.roles;
					params.keyWord = that.keyWord;
					params.pageIndex = that.page,
					params.pageSize = 10,
					params.searchType = "0"
					let success = this.transformCallBack();//成功回调
					let fail = this.transformFail();//失败回调
					console.log(JSON.stringify(params))
					mui.neiosRequst.httpRequst(url,params,function(ret){
						console.log(JSON.stringify(ret))
						if(ret.code == 0){
							that.hideOperBtn();
							if(that.page == 1){
								mui('#scroll').pullRefresh().enablePullupToRefresh();
								mui('#scroll').pullRefresh().endPullupToRefresh();
								that.list = [];
								that.list = ret.data.records
							}
							if(ret.data.current >= ret.data.pages){
								console.log("====================禁用====================") 
								mui('#scroll').pullRefresh().disablePullupToRefresh();
								mui('#scroll').pullRefresh().endPullupToRefresh(true);
							}
							else{
								mui('#scroll').pullRefresh().endPullupToRefresh();
								that.list = that.list.concat(ret.data.records)
							}
						}
					},function(err){
						console.log("失败回掉："+JSON.stringify(err))
					})
				},
				//列表信息成功回调
				transformCallBack(ret){
					// console.log("成功回掉："+JSON.stringify(ret))
				},
				//列表信息失败回调
				transformFail(err){
					// console.log("失败回掉："+JSON.stringify(err))
				},
				//办理单据
				doDocuments(){
					let params = {};
					let success = this.transformCallBack();//成功回调
					let fail = this.transformFail();//失败回调
					mui.neiosRequst.httpRequst("/app/common/getItemsByDictCodes",params,success,fail)
					mui.toast("点击办理按钮")
				},
				//删除数据操作 （通过修改 dataStatus为0）
				deleteItem(item){
					that.hideOperBtn();
					mui.confirm('是否删除','提示',['取消','确认'],function (e) {
						if(1 == e.index){
							let Former = mui.neioConfig.getTransForm(item,'0','0');
							
							let config = mui.neioConfig.getNeioConfig();
							let url = config.URL.saveOrUpdateTransOperate
							console.log(JSON.stringify(Former))
							// return;
							mui.neiosRequst.httpRequst(url,Former,function(ret){
							
								if(ret.code == 0){
									that.page = 1
									mui.toast(ret.msg)
									that.transformListGet()
								}
							},function(err){
								mui.toast(ret.msg)
								console.log("失败回掉："+JSON.stringify(err))
							})
						}
					},'div')

				},
				/**
				 * @param {Object} e 页面Url
				 * @param {Object} pageType 页面类型 （2，办理 0 详情 1 编辑 300新增）
				 * @param {Object} position 列表下标
				 * @param {Object} listType 列表类型 32 已提交 21已保存 90已办理(详情)
				 */
				navTo(e,pageType,position,listType){
					that.hideOperBtn();
					let param = {};
					//审批模式
					if('32' == listType && '100' != pageType){
						let workId = that.list[position].workId;
						let transOperateId = that.list[position].transOperateId;
						param.workId = workId;
						param.transOperateId = transOperateId;
						param.pageType = pageType;
						param.listType = listType;
						param.operateStaffName = that.list[position].operateStaffName;
						param.operateStaffCode = that.list[position].operateStaffCode;
						param.tutelageStaffCode = that.list[position].tutelageStaffCode;
						param.tutelageStaffName = that.list[position].tutelageStaffName;
						let config = mui.neioConfig.getNeioConfig();
						let pageKey = config.KEYS.PAGE_PARAM;
						mui.neioConfig.setStorage(pageKey,JSON.stringify(param))
					}
					//详情模式
					if('90' == listType && '100' != pageType){
						let transformerInfo = that.list[position];//变压器列表中的Item
						param.position = 0;//数据格式与procressing 保持一致 这里默认 0
						//迎合procressing  将数据装进 List 中
						param.data = [];
						param.data[0] = transformerInfo
						param.pageType = pageType;
						
						let config = mui.neioConfig.getNeioConfig();
						let pageKey = config.KEYS.PAGE_PARAM_TRANSFORM_INFO;
						mui.neioConfig.setStorage(pageKey,JSON.stringify(param))
					}
					if('100' == pageType || '200' == pageType || 300 == pageType){
						param.pageType = pageType;
						let config = mui.neioConfig.getNeioConfig();
						let pageKey = config.KEYS.PAGE_PARAM_TRANSFORM_INFO;
						mui.neioConfig.setStorage(pageKey,JSON.stringify(param))
					}

					mui.openWindow({
            			url: e,
            			id: e,
						extras: {},
					waiting: {
					autoShow: false
					}
        			});
				},
				//点击菜单
				menuClick(e){	
					this.navTo(e,'300','0','00')
				},
				//新增单据
				createForm(){
					let param = {};
					param.pageType = "0"; //0 录入|新增 1 展示/详情 2编辑修改 3办理,5办理离线
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM;
					console.log("----------"+JSON.stringify(param))
					mui.neioConfig.setStorage(pageKey,JSON.stringify(param))
					that.gotoPage("procressing.html",param)
				},
				//编辑单据
				formEdit(position){
					
					let param = {};
					let workId = that.list[position].workId;
					let transOperateId = that.list[position].transOperateId;
					param.workId = workId;
					param.transOperateId = transOperateId;
					param.pageType = '2'; //0 录入|新增 1 展示/详情 2编辑修改 3办理,5办理离线
					param.listType = '21';
					param.operateStaffName = that.list[position].operateStaffName;
					param.operateStaffCode = that.list[position].operateStaffCode;
					param.tutelageStaffCode = that.list[position].tutelageStaffCode;
					param.tutelageStaffName = that.list[position].tutelageStaffName;
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM;
					mui.neioConfig.setStorage(pageKey,JSON.stringify(param))
					
					that.gotoPage("procressing.html",param)
				},
				//详情
				detail(position){
					let param = {};
					let workId = that.list[position].workId;
					let transOperateId = that.list[position].transOperateId;
					param.workId = workId;
					param.transOperateId = transOperateId;
					param.pageType = '1'; //0 录入|新增 1 展示/详情 2编辑修改 3办理,5办理离线
					param.listType = '90';
					param.operateStaffName = that.list[position].operateStaffName;
					param.operateStaffCode = that.list[position].operateStaffCode;
					param.tutelageStaffCode = that.list[position].tutelageStaffCode;
					param.tutelageStaffName = that.list[position].tutelageStaffName;
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM;
					mui.neioConfig.setStorage(pageKey,JSON.stringify(param))
					console.log("详情参数:"+JSON.stringify(param))
					that.gotoPage("procressing.html",param)
				},
				//单据办理--在线状态
				doIt(position){
					let param = {};
					let workId = that.list[position].workId;
					let transOperateId = that.list[position].transOperateId;
					param.workId = workId;
					param.transOperateId = transOperateId;
					param.pageType = '3'; //0 录入|新增 1 展示/详情 2编辑修改 3办理,5办理离线
					param.listType = '32';
					param.operateStaffName = that.list[position].operateStaffName;
					param.operateStaffCode = that.list[position].operateStaffCode;
					param.tutelageStaffCode = that.list[position].tutelageStaffCode;
					param.tutelageStaffName = that.list[position].tutelageStaffName;
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM;
					mui.neioConfig.setStorage(pageKey,JSON.stringify(param))
					
					that.gotoPage("procressing.html",param)
				},
				//单据办理--离线状态
				doItForOutLine(position,data){
					let param = {};
					let workId = data[position].workId;
					let transOperateId = data[position].transOperateId;
					param.workId = workId;
					param.transOperateId = transOperateId;
					param.pageType = '3'; //0 录入|新增 1 展示/详情 2编辑修改 3办理,5办理离线
					param.listType = '32';
					param.operateStaffName = data[position].operateStaffName;
					param.operateStaffCode = data[position].operateStaffCode;
					param.tutelageStaffCode = data[position].tutelageStaffCode;
					param.tutelageStaffName = data[position].tutelageStaffName;
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM;
					mui.neioConfig.setStorage(pageKey,JSON.stringify(param))
					
					that.gotoPage("procressing.html",param)
				},
				//页面跳转
				gotoPage(url,param){
					that.hideOperBtn();
					mui.openWindow({
						url: url,
						id: url,
						extras: param,
						waiting: {
							autoShow: false
						}
					});
				},
				//左上角菜单显示隐藏
				showMenulist(){
					this.showMenu?this.showMenu=false:this.showMenu=true
				},
				//切换筛选条件
				changeFliter(e){
					this.filterText = e
				},
				showPop(){
					this.show_popup = true
				},
				hidePopup(){
					this.show_popup = false	
				},
				hideOperBtn () {
					$('.todo').css('width','0');
					$('.toAppoint').css('width','0');
				},
				
				
			}
			
			})

	
	// 显示操作按钮
	function showOperBtn (el) {
		console.log(el);
		$('.todo').css('width','0');
		$(el).next().css('width','39vw');
	}

	mui.init({
      pullRefresh: {
        container: "#scroll", //待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
        down: { //下拉刷新
		  style: 'circle',
          height: 50, //可选,默认50.触发下拉刷新拖动距离,
          auto: false, //可选,默认false.首次加载自动下拉刷新一次
          contentdown: "下拉可以刷新", //可选，在下拉可刷新状态时，下拉刷新控件上显示的标题内容
          contentover: "释放立即刷新", //可选，在释放可刷新状态时，下拉刷新控件上显示的标题内容
          contentrefresh: "正在刷新...", //可选，正在刷新状态时，下拉刷新控件上显示的标题内容
          callback: async function() { //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
            projectVM.page = 1;
			projectVM.keyWord = "";
            projectVM.transformListGet();
            ////没有更多内容了，endPulldown 传入true， 不再执行下拉刷新
			mui('#scroll').pullRefresh().endPulldownToRefresh();
			mui('#scroll').pullRefresh().enablePullupToRefresh();
			mui('#scroll').pullRefresh().endPullupToRefresh(true); 
        }
        },
        up: { //上拉加载
          height: 50, //可选.默认50.触发上拉加载拖动距离
          auto: false, //可选,默认false.自动上拉加载一次
          contentrefresh: "正在加载...", //可选，正在加载状态时，上拉加载控件上显示的标题内容
          contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
          callback: async function() { //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
			projectVM.page = projectVM.page + 1;
            projectVM.transformListGet();
          }
        }
      },
    });